package de.jmda.gen.java.impl;

import java.util.LinkedList;
import java.util.List;

import de.jmda.gen.Generator;
import de.jmda.gen.impl.AbstractCompoundGenerator;
import de.jmda.gen.java.MethodParametersGenerator;
import de.jmda.gen.java.ParametersGenerator;

public class DefaultMethodParametersGenerator
		extends AbstractCompoundGenerator
		implements MethodParametersGenerator
{
	private ParametersGenerator parametersGenerator;

	public DefaultMethodParametersGenerator()
  {
	  this(new DefaultParametersGenerator());
  }

	public DefaultMethodParametersGenerator(ParametersGenerator generator)
  {
	  super();
	  
	  if (generator == null)
	  {
	  	generator = new DefaultParametersGenerator();
	  }

	  setParametersGenerator(generator);
  }

	@Override
	public List<Generator> getGeneratorComponents()
	{
		List<Generator> result = new LinkedList<Generator>();

		result.add(dg("("));
		result.add(getParametersGenerator());
		result.add(dg(")"));

	  return result;
  }

	@Override
	public ParametersGenerator getParametersGenerator()
  {
  	return parametersGenerator;
  }

	@Override
	public void setParametersGenerator(ParametersGenerator generator)
  {
		if (generator == null)
		{
			return;
		}

		this.parametersGenerator = generator;
  }
}